<?php 
namespace  Slinks\common\io;

class FileRemovalVisitor implements IFileSystemVisitorWithFilter{
	
	/**
	 * This is called for evey object accessed during the traversal of the fielsystem by the FileSystemReader.
	 * @param SplFileInfo $info the SPLFileInfo object to represent the current portion of the file/directory tree.
	 */
	public function visit(\SplFileInfo $info){
		echo $info->getFilename();
	}
	
	
	/**
	 * Should create the Filter Iterator to be used. 
	 * This method will be provided with the base iterator that should be used when creating the FilterIterato
	 * The Iterator provided will contain SplFileInfo objects.
	 * @param Iterator $iterator the base iterator to be used when creating the FilterIterator. 
	 * @return FilterIterator filter to be used to filter the files that will be visited. 
	 */
	public function getFilterIterator(\Iterator $iterator){
		return new \RegexIterator($iterator, '/^.+\.php$/i', \RecursiveRegexIterator::GET_MATCH);
	}
	
}

